﻿<Window x:Class="centraldba_dbrestore_utility.frmStatusWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:centraldba_dbrestore_utility"
        mc:Ignorable="d"
        xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
        Title="Restore Status" 
        Height="400" 
        Width="500" 
        WindowStyle="ToolWindow" 
        WindowStartupLocation="CenterOwner" 
        ShowInTaskbar="False" 
        ResizeMode="NoResize" 
        Loaded="Window_Loaded" 
        SizeChanged="Window_SizeChanged">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="26" />
        </Grid.RowDefinitions>

        <DataGrid Name="dataGrid1" AutoGenerateColumns="False" Grid.Row="0" IsReadOnly="True" 
                  CanUserReorderColumns="False" 
                  CanUserSortColumns="False" 
                  GridLinesVisibility="None"
                  SelectionMode="Single"
                  xmlns:sys="clr-namespace:System;assembly=mscorlib">
            <DataGrid.Columns>
                <DataGridTemplateColumn Width="18">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Image x:Name="StatusImage" 
                                   Height="16" 
                                   Width="16" 
                                   RenderTransformOrigin="0.5, 0.5"
                                   Source="{Binding StatusImage}">
                                <Image.RenderTransform>
                                    <RotateTransform Angle="0" />
                                </Image.RenderTransform>
                                <Image.Style>
                                    <Style TargetType="{x:Type Image}">
                                        <Style.Triggers>
                                            <DataTrigger Binding="{Binding Path=Processing, FallbackValue=False}" Value="True">
                                                <DataTrigger.EnterActions>
                                                    <BeginStoryboard Name="Spinner">
                                                        <Storyboard Storyboard.TargetProperty="RenderTransform.(RotateTransform.Angle)">
                                                            <DoubleAnimation RepeatBehavior="Forever" From="0" To="360" BeginTime="0:0:0" Duration="0:0:2" />
                                                        </Storyboard>
                                                    </BeginStoryboard>
                                                </DataTrigger.EnterActions>
                                                <DataTrigger.ExitActions>
                                                    <RemoveStoryboard BeginStoryboardName="Spinner" />
                                                </DataTrigger.ExitActions>
                                            </DataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </Image.Style>
                            </Image>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>

                <DataGridTextColumn Header="Action" Binding="{Binding Name}" Width="*" />

                <DataGridHyperlinkColumn Header="Results" Width="75" ContentBinding="{Binding Status}">
                    <DataGridHyperlinkColumn.ElementStyle>
                        <Style TargetType="TextBlock">
                            <EventSetter Event="Hyperlink.Click" Handler="OnResultsClicked" />
                        </Style>
                    </DataGridHyperlinkColumn.ElementStyle>
                </DataGridHyperlinkColumn>
            </DataGrid.Columns>
        </DataGrid>

        <Button Name="cmdClose" Content="Close" Grid.Row="1" Click="cmdClose_Click" />

        <xctk:ChildWindow x:Name="wndResults" Caption="Step Results" Width="300" IsModal="True" WindowStartupLocation="Center">
            <Grid Margin="10">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                    <RowDefinition Height="26" />
                </Grid.RowDefinitions>

                <TextBlock TextWrapping="Wrap" Grid.Row="0"
                           Padding="5"
                           ToolTip="Command Executed"
                           FontSize="11"
                           FontFamily="Courier New"
                           Foreground="DarkGreen"
                           DataContext="{Binding ElementName=dataGrid1, Path=SelectedItem}"
                           Text="{Binding Command}" />

                <ScrollViewer Grid.Row="1">
                    <TextBlock TextWrapping="Wrap"
                               Padding="5"
                               ToolTip="Results"
                               FontSize="11"
                               FontFamily="Courier New"
                               DataContext="{Binding ElementName=dataGrid1, Path=SelectedItem}"
                               Text="{Binding Result}" />
                </ScrollViewer>

                <Button Grid.Row="2" Content="Close" Click="PopupClose_Click" />
            </Grid>
        </xctk:ChildWindow>
    </Grid>
</Window>
